<include file="Public:headern"/>
<div class="top"><a href="{$back}"><img src="__PUBLIC__/Catalog/nimages/tb.png"></a>
    <p>手机绑定</p>
</div>

<div class="S-reg login_reg">
   <form action="{:U('Membership/clocktel')}" id="clocktel" method="post">
    <div class="S-form_box">
       <div class="height25"></div>
       <p class="tPhone"><span class="m1">已绑定手机：</span><span class="m2">{$oldtel}</span></p>
       <ul>
         <li class="phone"><input type="text" id="tel" name="tel" placeholder="请输入您的手机号码" class="text" /><a  id="yzbutton" class="xym">获取验证码</a></li>
         <li class="xym">
	         <input type="text" name="yanzheng" id="yanzheng" placeholder="请输入您的手机验证码" class="text" />
	         <input type="hidden" name="yanzhengagain" id="yanzhengagain" value="" />
         </li>
       </ul>
       <input type="button" class="sub" id="tijiao" value="确认绑定" />
    </div>
   </form>
</div>

<script>
$(function(){
    if('{$msg}'!='0'){
        alert('{$msg}');
    }
});

$('#yzbutton').bind("click",function(){
	var tel = $('#tel').val();
	var isMobile=/^(?:13\d|15\d|18\d)\d{5}(\d{3}|\*{3})$/;
	
	if(isMobile.test(tel)){
    	 $.ajax({
    			type:"post",
    			url:"{:U('Membership/sendyzm')}",
    			datatype:'json',
    			data:{tel:tel},
    			success:function(result){
    				datacontent =window.JSON.parse(result);
    				if(datacontent.flag==1){
    					alert(datacontent.msg);
    				}else {
    					$('#yanzhengagain').val(datacontent.yanzhengma);
    					alert(datacontent.msg+datacontent.yanzhengma);
    				}
    				
    			},
    			error: function(XMLHttpRequest, textStatus, errorThrown) {
    				alert(XMLHttpRequest.status);
    				alert(XMLHttpRequest.readyState);
    				alert(textStatus);
    			},
    		});
     } else {
    	 alert("请正确填写电话号码，例如:13415764179"); 
     }
	
});

$('#tijiao').bind("click",function(){
	var yanzheng = $('#yanzheng').val();
	var yanzhengagain = $('#yanzhengagain').val();
	if(yanzheng==''){
		alert('验证码不能为空！');
		return false;
	}else{
		if(yanzheng!=yanzhengagain){
			alert('验证码输入错误！');
		}else{
			$('#clocktel').submit();
		}
	}
	
	
});
</script>
<include file="Public:footern" />
